<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\home\controller;

use think\Cache;
use think\Db;
use think\captcha\Captcha;

class Index extends Base
{
	public function index()
    {

        //获取轮播图
        $banner = Db::name("plug_ad")->select();
        $this->assign("banner",$banner);

        //关于我们
        $about_us = Db::name("page")->where("type=1")->find();
        $this->assign("about",$about_us);


        //分类
        $source=current(Db::name('category')->limit(1)->order("sort asc")->select());
        $this->assign("cate_name",$source['name']);
        $this->assign("cid",$source['id']);

        //获取商品
        $product = Db::name("product")->where("pro_type=1 AND cid!=".$source['id'])->order('sort asc')->limit(5)->select();
        $this->assign("product",$product);

        /**
         * 获取产品
         */
        $ca_product = Db::name("product")->where("cid=".$source['id']." AND pro_type=1")->limit(5)->select();
        $this->assign("ca_product",$ca_product);

        //获取文章
        $article = Db::name("news")->where("news_columnid=2 AND news_back=0")->order("listorder asc")->limit(2)->select();
        $this->assign("article",$article);
		return $this->view->fetch(':index');
	}
	
	/**
     * 关于我们
     */
    public function aboutUs()
    {
        $about_us = Db::name("page")->where("type=1")->find();
        $this->assign("about",$about_us);
        return $this->view->fetch(':about');
	}
	
	/**
     * 应用领域
     */
    public function scope()
    {
        $scope = Db::name("page")->where("type=4")->find();
        $this->assign("scope",$scope);
        return $this->view->fetch(':scope');
	}
	
	/**
     * 联系方式
     */
    public function connentUs()
    {
        $scope = Db::name("page")->where("type=3")->find();
        $this->assign("scope",$scope);
        return $this->view->fetch(':connent');
	}

}